import axios from "axios";
import Vue from 'vue'

const baseURL = "http://127.0.0.1:8080";

//  const baseURL = "http://49.232.130.18:8080/"
// Set config defaults when creating the instance
const http = axios.create({
    baseURL: baseURL
});


// 添加响应拦截器
http.interceptors.response.use(function (response) {
    // 对响应数据做点什么
    if (response.data.showType == 3) {
        Vue.prototype.$q.notify({
            message: response.data.msg,
            position: 'top',
            color: 'positive'
        })
    }
    return response.data.data;
}, function (error) {
    let response = error.response;
    Vue.prototype.$q.notify({
        message: response.data.errMsg,
        position: 'top',
        color: 'negative'
    })
    // 对响应错误做点什么
    return Promise.reject(error);
});

const PressureTest = {

    start: function (data) {
        return http.post('/pressureTest/start', data);
    },

    stop: function () {
        return http.post('/pressureTest/stop', {});
    }
}

export { PressureTest }